package main

import (
	"fmt"
	"os"
	"strconv"
)

func bmi(weight float64, height float64) float64 {
	return weight / (height * height)
}

func check_status(bmi float64) string {
	st := ""

	switch {
	case bmi <= 18.4:
		st = "偏瘦"
	case bmi >= 18.5 && bmi <= 23.9:
		st = "正常"
	case bmi >= 24.0 && bmi <= 27.9:
		st = "过重"
	default:
		st = "肥胖"
	}

	return st
}

func main() {
	if len(os.Args) != 3 {
		fmt.Println("gbmi 身高 体重")
		os.Exit(1)
	}

	height, herr := strconv.ParseFloat(os.Args[1], 64)
	if herr != nil {
		os.Exit(1)
	}

	weight, werr := strconv.ParseFloat(os.Args[2], 64)
	if werr != nil {
		os.Exit(1)
	}

	num := bmi(weight, height)

	fmt.Printf("身高(M) ： %.2fM\n", height)
	fmt.Printf("体重(Kg)： %.2fKg\n", weight)
	fmt.Printf("BMI     ： %.2f%%\n", num)
	fmt.Printf("状态    ： %s", check_status(num))

}